package vlasovserg.tennis.controllers;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import vlasovserg.tennis.entities.Match;
import vlasovserg.tennis.services.GameServices;
import java.util.List;

@Controller
@RequiredArgsConstructor
public class MatchController {

    //внедряем возможность использования иструментов GameService
    private final GameServices gameService;

    @GetMapping("/main")
    public String getMainPage(Model model) {
        List<Match> allMatches = this.gameService.getAllMatches();
        model.addAttribute("matches", allMatches);
        return "mainPage";
    }
}
